import React, { Component } from 'react';
import DemoC1 from './Child';
class DemoP1 extends Component {
    state = { 
      price: 10
    } 
    updatePrice = (price)=> {
     this.setState({
       price
     })
    }
    render() { 
        return (<div>
          <h3>7.2. 子组件给父子组件传值-回调函数方式</h3>
           <p>父组件</p>
           当前榴莲价格为：{this.state.price}
           <DemoC1 updatePrice={this.updatePrice} price={this.state.price} />
        </div>);
    }
}
 
export default DemoP1;